﻿using CoreModule.Storages;
using System.Windows;

namespace IdResourceModule.Views
{
    /// <summary>
    /// DbHome.xaml 的交互逻辑
    /// </summary>
    public partial class DbHome : Window
    {
        public DbHome()
        {
            InitializeComponent();
        }

        public DbStorageConfiguration DbStorageConfiguration { get; set; }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            DbStorageConfiguration.MySqlConnectionString = DbStorageConfiguration.MySqlConnectionString.Trim();
            DbStorageConfiguration.MsSqlConnectionString = DbStorageConfiguration.MsSqlConnectionString.Trim();
            DbStorageConfiguration.OracleConnectionString = DbStorageConfiguration.OracleConnectionString.Trim();
            DbStorageConfiguration.Save();

            var String_Save_System_Configuration_Successfully= WPFLocalizeExtension.Engine.LocalizeDictionary.Instance.GetLocalizedObject("String_Save_System_Configuration_Successfully", null, null) + "!";
            MessageBox.Show(String_Save_System_Configuration_Successfully);
            this.Close();

        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            DbStorageConfiguration = DbStorageConfiguration.Load();
            this.DataContext = DbStorageConfiguration;
        }
    }
}
